package com.lin.utils;

import java.util.HashMap;
import java.util.Map;

public class DecimalUtil {
    // 定义 62 进制的字符表
    private static final String BASE_62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

    // 10进制转62进制
    public static String decimalTo62Base(long decimalNumber) {
        StringBuilder result = new StringBuilder();
        Map<Character, Long> charValueMap = new HashMap<>();

        // 初始化字符与对应值的映射
        for (int i = 0; i < BASE_62_CHARS.length(); i++) {
            charValueMap.put(BASE_62_CHARS.charAt(i), (long) i);
        }

        while (decimalNumber > 0) {
            long remainder = decimalNumber % 62;
            result.append(BASE_62_CHARS.charAt((int) remainder));
            decimalNumber /= 62;
        }

        return result.reverse().toString();
    }
}
